package com.bosssoft.hr.jobmonitor.service.impl;

import com.bosssoft.hr.jobmonitor.entity.User;
import com.bosssoft.hr.jobmonitor.entity.UserExample;
import com.bosssoft.hr.jobmonitor.mapper.UserMapper;
import com.bosssoft.hr.jobmonitor.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
/***
 * @Author lys(cherish)
 * @Description 用户服务数据库实现
 * @Date  2019/2/26
 **/
@Service
public class DBUserServiceImpl implements IUserService {

    //用户数据Dao注入
    @Autowired
    private UserMapper userMapper;

    /***
     * @Author lys(cherish)
     * @Description 查询所有用户
     * @Date  2019/2/26
     * @Param []
     * @return java.util.List<com.bosssoft.hr.jobmonitor.entity.User>
     **/
    @Override
    public List<User> queryAllUser() {
       return userMapper.selectByExample(new UserExample());
    }

    /***
     * @Author lys(cherish)
     * @Description 根据用户ID查询用户
     * @Date  2019/2/26
     * @Param [id]
     * @return com.bosssoft.hr.jobmonitor.entity.User
     **/
    @Override
    public User getUserById(Integer id) {
        return userMapper.selectByPrimaryKey(id);
    }

    /***
     * @Author lys(cherish)
     * @Description 保存用户
     * @Date  2019/2/26
     * @Param [user]
     * @return void
     **/
    @Override
    public void saveUser(User user) {
         userMapper.insert(user);
    }

    /***
     * @Author lys(cherish)
     * @Description 根据用户ID删除用户
     * @Date  2019/2/26
     * @Param [id]
     * @return com.bosssoft.hr.jobmonitor.entity.User
     **/
    @Override
    public User deleteUserById(Integer id) {
        return deleteUserById(id);
    }

}
